package com.metaera.app.controller.view;

import android.app.Activity;
import android.content.Intent;

import com.metaera.app.LocalConfigStore;
import com.metaera.app.controller.view.core.INetworkRequestView;
import com.metaera.app.data.model.UserDetailsResponse;
import com.metaera.app.ui.activities.MainActivity;
import com.metaera.app.utils.SoftKeyBoardUtils;
import com.umeng.analytics.MobclickAgent;

import org.greenrobot.eventbus.EventBus;


public class LoginView implements INetworkRequestView<UserDetailsResponse> {

    private final Activity activity;

    public LoginView(Activity activity) {

        this.activity = activity;
    }

    @Override
    public void successful(UserDetailsResponse data) {
        MobclickAgent.onProfileSignIn("uid:" + data.getId());

        EventBus.getDefault().post(data);

        SoftKeyBoardUtils.hind(activity);

        LocalConfigStore.getInstance().saveUser(data);

        activity.startActivity(new Intent(activity, MainActivity.class));
    }

}
